package com.knoya.chejian.pda.myadapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.knoya.chejian.pda.R
import com.knoya.chejian.pda.module.zupanchaxun.ZupanChaxunBean
import com.knoya.chejian.pda.util.Myutil
import kotlinx.android.synthetic.main.item_zupan_chaxun.view.*

class ZupanChaxunAdapter(private var mlist: List<ZupanChaxunBean>, private val mcontext: Context) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v : View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.item_zupan_chaxun,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        var bean = mlist[position]
        Myutil.settv(bean.pallet_num,h.Tv_pallet_num)
        Myutil.settv(bean.onum,h.Tv_Onum)
        Myutil.settv(bean.position,h.Tv_Position)
        Myutil.settv(bean.position_buffer,h.Tv_Buffer)
        return v
    }

    override fun getItem(position: Int): Any {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return mlist.size
    }
    class Header(var v : View){
        val Tv_Buffer=v.Tv_Buffer
        val Tv_Onum=v.Tv_Onum
        val Tv_Position=v.Tv_Position
        val Tv_pallet_num=v.Tv_pallet_num

    }
}